//
//  UIImage+Color.m
//  AFNetworking
//
//  Created by 翁胜琼 on 2019/2/13.
//

#import "UIImage+Color.h"

@implementation UIImage (Color)

+ (instancetype)sq_imageWithColor:(UIColor *)color size:(CGSize)size
{
    CGRect rect=CGRectMake(0.0f, 0.0f, size.width,size.height);
    UIGraphicsBeginImageContext(size);//创建图片
    CGContextRef context = UIGraphicsGetCurrentContext();//创建图片上下文
    CGContextSetFillColorWithColor(context, [color CGColor]);//设置当前填充颜色的图形上下文
    CGContextFillRect(context, rect);//填充颜色
    
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}

+ (instancetype)sq_imageWithColor:(UIColor *)color
{
    return [self sq_imageWithColor:color size:CGSizeMake(1, 1)];
}
@end
